from main import db
from sqlalchemy.exc import InvalidRequestError
from main.utils import JSONHelper
from datetime import datetime, date
from sqlalchemy import or_, and_, func
from main.models import User


# user

def query_user_by_id(id):
    return User.query.filter(User.id == id).first()


def query_user_by_phone(phone):
    return User.query.filter(User.phone == phone).first()


def query_user_by_username(username):
    return User.query.filter(User.username == username).first()


def query_user_by_openid(openid):
    return db.session.query(User).filter(User.openid == openid).first()

